<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <style>
        #overlay {
            background:rgba(0, 0, 0, 0.6);
            width: 100%;
            margin: auto;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            right: 0;
            bottom: 0;
        }

        #center {
            background: #ffff;
            border-radius: 5px;
            padding-top: 15px;
            padding-left: 30px;
            padding-bottom: 15;
            width: 290px;
            height: 160px;
            position: fixed;
            margin:auto;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
        }
    </style>
</head>
<body>
    <div id="box">  
        <button @click="isShow=true">show</button>

        <!-- <div id="overlay" v-show="isShow" @click="isShow=false">
            <div id="center" @click.stop>
                <div>用户名: <input type="text"> </div>
                <div>密码: <input type="password"> </div>
                <div> <button @click="isShow=false">登陆</button> </div>
            </div>
        </div>        第一种实现方式stop-->

            
        <div id="overlay" v-show="isShow" @click.self="isShow=false">
            <div id="center">
                <div>用户名: <input type="text"> </div>
                <div>密码: <input type="password"> </div>
                <div> <button @click="isShow=false">登陆</button> </div>
            </div>
        </div>


    </div>

    <script>
        var vm = new Vue ({
            el:"#box",
            data: {
                isShow: false,
            }
        })
    </script>
</body>
</html>